package com.depth.viewer.utils
{
	import flash.display.DisplayObject;
	import flash.display.Stage;
	
	import mx.core.FlexGlobals;
	import mx.core.IFlexDisplayObject;
	import mx.managers.PopUpManager;

	public class WaitBar
	{
		public function WaitBar()
		{
		}
		
		private static var _instance:WaitBar;
		private var loading:Boolean = false;
		
		public static function get instance():WaitBar{
			if(_instance == null){
				_instance = new WaitBar();
			}
			return _instance;
		}
		
		public function show(display:Boolean,text:String = ""):void{
			if(display){
				if(loading)
					return;
				loading = true;
				MyProgressBar.instance.run(text);
				PopUpManager.addPopUp(MyProgressBar.instance as IFlexDisplayObject,
					FlexGlobals.topLevelApplication as DisplayObject);
			}else{
				if(loading){
					loading = false;
					MyProgressBar.instance.stop();
					PopUpManager.removePopUp(MyProgressBar.instance);
				}
			}
		}
	}
}